package com.demo.bio.three;


import java.io.OutputStream;
import java.io.PrintStream;
import java.net.Socket;
import java.util.Scanner;

/**
 *
 * @author wangning
 * @create 2022-01-04 21:22
 */
public class Client3 {
	public static void main(String[] args) throws Exception {

		// 1.创建一个socket对象，请求服务端的连接
		Socket socket = new Socket("127.0.0.1", 9999);
		// 2.从socket对象中获取一个字节输出流
		OutputStream os = socket.getOutputStream();
		// 3.把字节输出流包装成一个打印流
		PrintStream ps = new PrintStream(os);
		Scanner scanner = new Scanner(System.in);

		while (true) {
			System.out.print("请输入：");
			String msg = scanner.nextLine();
			ps.println(msg);
			ps.flush();

		}

	}

}
